package com.hishop.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hishop.common.utils.PageUtils;
import com.hishop.coupon.dao.CouponSpuRelationDao;
import com.hishop.coupon.entity.CouponSpuRelationEntity;
import com.hishop.coupon.service.CouponSpuRelationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service("couponSpuRelationService")
public class CouponSpuRelationServiceImpl extends ServiceImpl<CouponSpuRelationDao, CouponSpuRelationEntity> implements CouponSpuRelationService {

    @Resource
    private CouponSpuRelationDao couponSpuRelationDao;

    @Override
    public PageUtils queryPage(String key, Page<CouponSpuRelationEntity> page) {
        QueryWrapper<CouponSpuRelationEntity> qw = new QueryWrapper<>();
        if (!key.equals("")) {
            qw.like("id", key)
                    .or().like("coupon_id",key)
                    .or().like("spu_id",key)
                    .or().like("spu_name",key)
            ;
        }
        return new PageUtils(couponSpuRelationDao.selectPage(page,qw));
    }

}